<?php

namespace Sm\AssBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;

/**
 * Style
 *
 * @ORM\Table("sm_style")
 * @ORM\Entity(repositoryClass="Sm\AssBundle\Entity\StyleRepository")
 * @ORM\Entity(repositoryClass="Sm\AssBundle\Entity\StyleRepository")
 * @UniqueEntity("name")
 */

class Style
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * 
     * @ORM\ManyToOne(targetEntity="Sm\AssBundle\Entity\Ass", inversedBy="styles")
     * @ORM\JoinColumn(nullable=false) 
     */
    private $ass;
    
    /**
     * @var string
     *
     * @ORM\Column(name="fontname", type="string", length=255)
     */
    private $fontname;
    
    /**
     * @var string
     *
     * @ORM\Column(name="name", type="string", length=255)
     */
    private $name;

    /**
     * @var string
     *
     * @ORM\Column(name="fontsize", type="string", length=255)
     */
    private $fontsize;

    /**
     * @var string
     *
     * @ORM\Column(name="primarycolour", type="string", length=255)
     */
    private $primarycolour;

    /**
     * @var string
     *
     * @ORM\Column(name="secondarycolour", type="string", length=255)
     */
    private $secondarycolour;

    /**
     * @var string
     *
     * @ORM\Column(name="outlinecolour", type="string", length=255)
     */
    private $outlinecolour;

    /**
     * @var string
     *
     * @ORM\Column(name="backcolour", type="string", length=255)
     */
    private $backcolour;

    /**
     * @var integer
     *
     * @ORM\Column(name="bold", type="integer")
     */
    private $bold;

    /**
     * @var integer
     *
     * @ORM\Column(name="italic", type="integer")
     */
    private $italic;

    /**
     * @var integer
     *
     * @ORM\Column(name="underline", type="integer")
     */
    private $underline;

    /**
     * @var integer
     *
     * @ORM\Column(name="strikeout", type="integer")
     */
    private $strikeout;

    /**
     * @var integer
     *
     * @ORM\Column(name="scalex", type="integer")
     */
    private $scalex;

    /**
     * @var integer
     *
     * @ORM\Column(name="scaley", type="integer")
     */
    private $scaley;

    /**
     * @var float
     *
     * @ORM\Column(name="borderstyle", type="float")
     */
    private $borderstyle;

    /**
     * @var float
     *
     * @ORM\Column(name="outline", type="float")
     */
    private $outline;

    /**
     * @var float
     *
     * @ORM\Column(name="shadow", type="float")
     */
    private $shadow;

    /**
     * @var float
     *
     * @ORM\Column(name="alignment", type="float")
     */
    private $alignment;

    /**
     * @var float
     *
     * @ORM\Column(name="marginl", type="float")
     */
    private $marginl;

    /**
     * @var float
     *
     * @ORM\Column(name="marginr", type="float")
     */
    private $marginr;

    /**
     * @var float
     *
     * @ORM\Column(name="marginv", type="float")
     */
    private $marginv;

    /**
     * @var integer
     *
     * @ORM\Column(name="encoding", type="integer")
     */
    private $encoding;

    /**
     * @ORM\OneToMany(targetEntity="Sm\AssBundle\Entity\Srt", mappedBy="style")
     * @ORM\JoinColumn(nullable=false) 
     */
    private $srts;

    /*
     * Constructor
     */
    public function __construct($options) {
        
        $defaults = $this->getDefaultOptions();
        
        $this->name             = isset($options['name']) ? $options['name'] : $defaults['name'];
        $this->fontname         = isset($options['fontname']) ? $options['fontname'] : $defaults['fontname'];
        $this->fontsize         = isset($options['fontsize']) ? $options['fontsize'] : $defaults['fontsize'];
        $this->primarycolour    = isset($options['primarycolour']) ? $options['primarycolour'] : $defaults['primarycolour'];
        $this->secondarycolour  = isset($options['secondarycolour']) ? $options['secondarycolour'] : $defaults['secondarycolour'];
        $this->outlinecolour    = isset($options['outlinecolour']) ? $options['outlinecolour'] : $defaults['outlinecolour'];
        $this->backcolour       = isset($options['backcolour']) ? $options['backcolour'] : $defaults['backcolour'];
        $this->bold             = isset($options['bold']) ? $options['bold'] : $defaults['bold'];
        $this->italic           = isset($options['italic']) ? $options['italic'] : $defaults['italic'];
        $this->underline        = isset($options['underline']) ? $options['underline'] : $defaults['underline'];
        $this->strikeout        = isset($options['strikeout']) ? $options['strikeout'] : $defaults['strikeout'];
        $this->scalex           = isset($options['scalex']) ? $options['scalex'] : $defaults['scalex'];
        $this->scaley           = isset($options['scaley']) ? $options['backcolour'] : $defaults['backcolour'];
        $this->borderstyle      = isset($options['borderstyle']) ? $options['borderstyle'] : $defaults['borderstyle'];
        $this->outline          = isset($options['outline']) ? $options['outline'] : $defaults['outline'];
        $this->shadow           = isset($options['shadow']) ? $options['shadow'] : $defaults['shadow'];
        $this->alignment        = isset($options['alignment']) ? $options['alignment'] : $defaults['alignment'];
        $this->marginl          = isset($options['marginl']) ? $options['marginl'] : $defaults['marginl'];
        $this->marginr          = isset($options['marginr']) ? $options['marginr'] : $defaults['marginr'];
        $this->marginv          = isset($options['marginv']) ? $options['marginv'] : $defaults['marginv'];
        $this->encoding         = isset($options['encoding']) ? $options['encoding'] : $defaults['encoding'];
        $this->ass              = isset($options['ass']) ? $options['ass'] : $defaults['ass'];
    }
    
    /*
     * Default style options
     */
    private function getDefaultOptions() {
        
        return array(
            'name' => 'Default',
            'fontname' => 'Jester',
            'fontsize' => '55',
            'primarycolour' => '00FFFFFF',
            'secondarycolour' => '000FFFF',
            'outlinecolour' => '0000000',
            'backcolour' => '80000000',
            'bold' => 'Default',
            'italic' => 'Default',
            'underline' => 0,
            'strikeout' => 0,
            'scalex' => 100,
            'scaley' => 100,
            'borderstyle' => 1,
            'outline' => 1.8,
            'shadow' => 0,
            'alignment' => 2,
            'marginl' => 10,
            'marginr' => 10,
            'marginv' => 20,
            'encoding' => 1.8,
            'ass' => null
        );
    }
    
    public function __ToString() {
        
        return $this->name;
        
    }
    
    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set name
     *
     * @param string $name
     * @return Style
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }

    /**
     * Get name
     *
     * @return string 
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Set fontname
     *
     * @param string $fontname
     * @return Style
     */
    public function setFontname($fontname)
    {
        $this->fontname = $fontname;

        return $this;
    }

    /**
     * Get fontname
     *
     * @return string 
     */
    public function getFontname()
    {
        return $this->fontname;
    }

    /**
     * Set fontsize
     *
     * @param string $fontsize
     * @return Style
     */
    public function setFontsize($fontsize)
    {
        $this->fontsize = $fontsize;

        return $this;
    }

    /**
     * Get fontsize
     *
     * @return string 
     */
    public function getFontsize()
    {
        return $this->fontsize;
    }

    /**
     * Set primarycolour
     *
     * @param string $primarycolour
     * @return Style
     */
    public function setPrimarycolour($primarycolour)
    {
        $this->primarycolour = $primarycolour;

        return $this;
    }

    /**
     * Get primarycolour
     *
     * @return string 
     */
    public function getPrimarycolour()
    {
        return $this->primarycolour;
    }

    /**
     * Set secondarycolour
     *
     * @param string $secondarycolour
     * @return Style
     */
    public function setSecondarycolour($secondarycolour)
    {
        $this->secondarycolour = $secondarycolour;

        return $this;
    }

    /**
     * Get secondarycolour
     *
     * @return string 
     */
    public function getSecondarycolour()
    {
        return $this->secondarycolour;
    }

    /**
     * Set outlinecolour
     *
     * @param string $outlinecolour
     * @return Style
     */
    public function setOutlinecolour($outlinecolour)
    {
        $this->outlinecolour = $outlinecolour;

        return $this;
    }

    /**
     * Get outlinecolour
     *
     * @return string 
     */
    public function getOutlinecolour()
    {
        return $this->outlinecolour;
    }

    /**
     * Set backcolour
     *
     * @param string $backcolour
     * @return Style
     */
    public function setBackcolour($backcolour)
    {
        $this->backcolour = $backcolour;

        return $this;
    }

    /**
     * Get backcolour
     *
     * @return string 
     */
    public function getBackcolour()
    {
        return $this->backcolour;
    }

    /**
     * Set bold
     *
     * @param integer $bold
     * @return Style
     */
    public function setBold($bold)
    {
        $this->bold = $bold;

        return $this;
    }

    /**
     * Get bold
     *
     * @return integer 
     */
    public function getBold()
    {
        return $this->bold;
    }

    /**
     * Set italic
     *
     * @param integer $italic
     * @return Style
     */
    public function setItalic($italic)
    {
        $this->italic = $italic;

        return $this;
    }

    /**
     * Get italic
     *
     * @return integer 
     */
    public function getItalic()
    {
        return $this->italic;
    }

    /**
     * Set underline
     *
     * @param integer $underline
     * @return Style
     */
    public function setUnderline($underline)
    {
        $this->underline = $underline;

        return $this;
    }

    /**
     * Get underline
     *
     * @return integer 
     */
    public function getUnderline()
    {
        return $this->underline;
    }

    /**
     * Set strikeout
     *
     * @param integer $strikeout
     * @return Style
     */
    public function setStrikeout($strikeout)
    {
        $this->strikeout = $strikeout;

        return $this;
    }

    /**
     * Get strikeout
     *
     * @return integer 
     */
    public function getStrikeout()
    {
        return $this->strikeout;
    }

    /**
     * Set scalex
     *
     * @param integer $scalex
     * @return Style
     */
    public function setScalex($scalex)
    {
        $this->scalex = $scalex;

        return $this;
    }

    /**
     * Get scalex
     *
     * @return integer 
     */
    public function getScalex()
    {
        return $this->scalex;
    }

    /**
     * Set scaley
     *
     * @param integer $scaley
     * @return Style
     */
    public function setScaley($scaley)
    {
        $this->scaley = $scaley;

        return $this;
    }

    /**
     * Get scaley
     *
     * @return integer 
     */
    public function getScaley()
    {
        return $this->scaley;
    }

    /**
     * Set borderstyle
     *
     * @param float $borderstyle
     * @return Style
     */
    public function setBorderstyle($borderstyle)
    {
        $this->borderstyle = $borderstyle;

        return $this;
    }

    /**
     * Get borderstyle
     *
     * @return float 
     */
    public function getBorderstyle()
    {
        return $this->borderstyle;
    }

    /**
     * Set outline
     *
     * @param float $outline
     * @return Style
     */
    public function setOutline($outline)
    {
        $this->outline = $outline;

        return $this;
    }

    /**
     * Get outline
     *
     * @return float 
     */
    public function getOutline()
    {
        return $this->outline;
    }

    /**
     * Set shadow
     *
     * @param float $shadow
     * @return Style
     */
    public function setShadow($shadow)
    {
        $this->shadow = $shadow;

        return $this;
    }

    /**
     * Get shadow
     *
     * @return float 
     */
    public function getShadow()
    {
        return $this->shadow;
    }

    /**
     * Set alignment
     *
     * @param float $alignment
     * @return Style
     */
    public function setAlignment($alignment)
    {
        $this->alignment = $alignment;

        return $this;
    }

    /**
     * Get alignment
     *
     * @return float 
     */
    public function getAlignment()
    {
        return $this->alignment;
    }

    /**
     * Set marginl
     *
     * @param float $marginl
     * @return Style
     */
    public function setMarginl($marginl)
    {
        $this->marginl = $marginl;

        return $this;
    }

    /**
     * Get marginl
     *
     * @return float 
     */
    public function getMarginl()
    {
        return $this->marginl;
    }

    /**
     * Set marginr
     *
     * @param float $marginr
     * @return Style
     */
    public function setMarginr($marginr)
    {
        $this->marginr = $marginr;

        return $this;
    }

    /**
     * Get marginr
     *
     * @return float 
     */
    public function getMarginr()
    {
        return $this->marginr;
    }

    /**
     * Set marginv
     *
     * @param float $marginv
     * @return Style
     */
    public function setMarginv($marginv)
    {
        $this->marginv = $marginv;

        return $this;
    }

    /**
     * Get marginv
     *
     * @return float 
     */
    public function getMarginv()
    {
        return $this->marginv;
    }

    /**
     * Set encoding
     *
     * @param integer $encoding
     * @return Style
     */
    public function setEncoding($encoding)
    {
        $this->encoding = $encoding;

        return $this;
    }

    /**
     * Get encoding
     *
     * @return integer 
     */
    public function getEncoding()
    {
        return $this->encoding;
    }

    /**
     * Set ass
     *
     * @param \Sm\AssBundle\Entity\Ass $ass
     * @return Style
     */
    public function setAss(\Sm\AssBundle\Entity\Ass $ass)
    {
        $this->ass = $ass;

        return $this;
    }

    /**
     * Get ass
     *
     * @return \Sm\AssBundle\Entity\Ass 
     */
    public function getAss()
    {
        return $this->ass;
    }

    /**
     * Set id
     *
     * @param string $id
     * @return Style
     */
    public function setId($id)
    {
        $this->id = $id;

        return $this;
    }

    /**
     * Add srts
     *
     * @param \Sm\AssBundle\Entity\Srt $srts
     * @return Style
     */
    public function addSrt(\Sm\AssBundle\Entity\Srt $srts)
    {
        $this->srts[] = $srts;

        return $this;
    }

    /**
     * Remove srts
     *
     * @param \Sm\AssBundle\Entity\Srt $srts
     */
    public function removeSrt(\Sm\AssBundle\Entity\Srt $srts)
    {
        $this->srts->removeElement($srts);
    }

    /**
     * Get srts
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getSrts()
    {
        return $this->srts;
    }
    
}
